<form action="<?php echo WebRoot.'controllers/editAlbum.php';?>" method="post">
  <fieldset>    
    <legend><?php echo isset($editAlbum) ? T_('Edit Album') : T_('Create Album');?></legend><br />
    
    <?php if(isset($editAlbum)) { ?>    
    <input type="hidden" name="album[idAlbum]" value="<?php echo $editAlbum->idAlbum;?>" />
    <?php } ?>
    
    <label for="formName"><?php echo T_('Name'); ?></label><span class="requiredField">(<?php echo T_('required'); ?>)</span><br />
    <input type="text" name="album[name]" maxlength="30" title="<?php echo T_('Album will be displayed with this name') ?>" class="tooltipTitle" id="formName" value="<?php echo isset($editAlbum) ? $editAlbum->Name : '';?>" /><br />
    
    <label for="formDescription"><?php echo T_('Description'); ?></label><br />
    <input type="text" name="album[description]" maxlength="255" title="<?php echo T_('More informations about album.') ?>" class="tooltipTitle" id="formDescription" value="<?php echo isset($editAlbum) ? $editAlbum->Description : '' ;?>" /><br />
    
    <label for="formParent"><?php echo T_('ID Parent'); ?></label><br />
    <select name="album[parent]" id="formParent" title="<?php echo T_('You can specify, where will be album listed to.'); ?>" class="tooltipTitle">
      <option value="null">-</option>
      <?php 
        foreach ($user->Albums as $album) {
          echo '<option ';
          if (isset($_GET['parentAlbum']) && $_GET['parentAlbum'] == $album->idAlbum) echo 'selected="selected"';
          if (isset($editAlbum) && $editAlbum->ParentAlbum == $album ) echo 'selected="selected"';
          echo 'value="'.$album->idAlbum.'">'.$album->Name.'</option>';
        }  
      ?>
    </select><br />
    
    <label for="formProtection"><?php echo T_('Protection'); ?></label><br />
    <select name="album[protection]" id="formProtection">
      <?php 
        T_('Entry is possible only after entering the password');
        T_('Content of an album can only see users that you define');
        T_('Only registered users can see the contents of the album');
        T_('Everyone can see the contents of the album');
      
        $qb= $db->createQuery('SELECT p FROM Protection p ORDER BY p.protection DESC');
        $protections = $qb->getResult();
        foreach ($protections as $protection) {
          echo '<option class="tooltipTitle" title="'.T_($protection->Description).'"';
          if(isset($editAlbum) && $editAlbum->Protection == $protection) echo 'selected="selected"';
          echo 'value="'.$protection->Protection.'">'.$protection->Protection.'</option>';
        }  
      ?>
    </select>
    
    <label id="formPasswordLabel" for="formPassword"><?php echo T_('Password'); ?></label>
    <input type="text" name="album[password]" id="formPassword" value="<?php echo isset($editAlbum) ? $editAlbum->Password : '';?>" />
    
    <label id="autocompleteUserLabel" for="formPassword"><?php echo T_('Add user'); ?></label>
    <input type="text" id="autocompleteUser"/><img id="autocompleteUserLoading" src ="<?php echo WebRoot; ?>/themes/<?php echo $theme; ?>/images/loading.gif" alt="loading" />
    <div id="placeForCheckBox">
      <div class=""><?php echo T_('Users with access to album'); ?></div>
      <?php
        if (isset($editAlbum) && $editAlbum->AllowedUsers !== null)
          foreach($editAlbum->AllowedUsers as $allowedUser) {
            echo '<div class="checkBoxes-saved"><input type="checkbox" checked="checked" id="ac_'.$allowedUser->UserName.'" name="allowedUsers[]" value="'.$allowedUser->UserName.'" />
                  <label for="ac_'.$allowedUser->UserName.'">'.$allowedUser->UserName.'</label></div>';
          }  
      ?>
     <div class="clear"></div>   
    </div>
    
    <br />
    <label title="<?php echo T_('Enable or disable adding comments to photos') ?>" class="tooltipTitle" for="formComments"><?php echo T_('Allow comments'); ?></label>
    <input title="<?php echo T_('Enable or disable adding comments to photos') ?>" class="tooltipTitle" type="checkbox" name="album[comments]" <?php echo (!isset($editAlbum) || $editAlbum->AllowComments) ? 'checked="checked"' : '' ;?> id="formComments" />    
    <br />
    
    <input type="submit" name="album[submit]" value="<?php echo T_('Create'); ?>" />
  </fieldset>
</form>  

